package com.yxhl.zoume.domain.interactor.passenger;

import com.yxhl.zoume.data.http.repository.passenger.PassengerRepository;
import com.yxhl.zoume.data.http.rest.param.base.RequestParamImpl;
import com.yxhl.zoume.data.http.rest.param.passenger.AddPassengerParam;
import com.yxhl.zoume.data.http.rest.response.passenger.AddPassengerResponse;
import com.yxhl.zoume.domain.DomainConstants;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by sugarya on 16/3/20.
 */
public class AddPassengerUseCase extends com.yxhl.zoume.domain.interactor.base.UseCase<AddPassengerResponse> {
    private PassengerRepository passengerRepository;

    @Inject
    public AddPassengerUseCase(
            @Named(DomainConstants.UI_THREAD) Scheduler uiThread,
            @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
            PassengerRepository passengerRepository) {
        super(uiThread, executorThread);
        this.passengerRepository = passengerRepository;
    }

    @Override
    protected Observable<AddPassengerResponse> buildObservable(RequestParamImpl param) {
        return passengerRepository.addNewPassenger((AddPassengerParam) param)
                .subscribeOn(executorThread)
                .observeOn(uiThread);
    }
}
